#!/usr/bin/env python
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from google.appengine.dist import use_library
use_library('django', '1.2')

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from model import TopicM

class topicsHandler(webapp.RequestHandler):
    def post(self):
        lectureKey = self.request.get('key')
        TopicM.resetTopics(lectureKey)
        i = 1
        while(self.request.get("topic" + str(i))):
            topicName=self.request.get("topic" + str(i))
            TopicM.addTopic(topicName, lectureKey, i)
            i+=1
            
application = webapp.WSGIApplication([(r'.*', topicsHandler)],debug=True)

def main():
    run_wsgi_app(application)
    
if __name__ == '__main__':
    main()